﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<IPagedList<Message>>" %>
<%@ Import Namespace="ViewRes" %> 

<%
    if (Model.Count != 0)
    {%>
<table class="grid" width="95%">
    <tbody>
        <%
        foreach (Message message in Model)
        {%>
        <tr style="vertical-align: top;">
            <td class="smallgraytext" style="width: 135px;">
                <%:message.PubDate.ToString()%>
            </td>
            <td class="smallgreentext" style="width: auto;">
                <%:message.User.ToString()%>
            </td>
            <td style="width: auto;">
                <div >
                    <%:message.Text.Trim()%>
                </div>
            </td>
            <td style="width: 60px; text-align: center;">
                <%
            if (message.UserId == ((User) ViewData["LoggedUser"]).UserId)
            {%>
                     <%:Html.RouteLink(SharedStrings.Delete, "Default",
                                                 new
                                                     {
                                                         controller = "Messages",
                                                         action = "Delete",
                                                         messageId = message.MessageId,
                                                         currentPage = ViewData.Model.PageNumber
                                                     },
                                                 new {@class = "deleteMessageLink", style = "display:none;"})%>
                <%
            }%>
            </td>
        </tr>
        <%
        }%>
    </tbody>
</table>
<div class="pager">
    <%=Html.Pager("divGrid", ViewData.Model.PageSize, ViewData.Model.PageNumber,
                                     ViewData.Model.TotalItemCount,
                                     new
                                         {
                                             controller = "Messages",
                                             action = "MessagesByPage",
                                             roomId = Model[0].CollaborationRoomId
                                         })%>
</div>
<%
    } %>
<%
    else
    {%>
    <span class="smalltitle"><%:MessagesStrings.NoMessage%></span>
<%
    }%>
